﻿using System.Collections.Generic;

namespace Tszy.Unlimited.Data.AdoNet.Sql.Descriptors
{
    /// <summary>
    /// 函数表达式描述器。
    /// </summary>
    public interface IWhereCallExpressionDescriptor
    {
        /// <summary>
        ///
        /// </summary>
        WhereLikeCallExpressionParameter Like { get; }

        /// <summary>
        ///
        /// </summary>
        WhereInCallExpressionParameter In { get; }

        /// <summary>
        ///
        /// </summary>
        WhereNotInCallExpressionParameter NotIn { get; }

        /// <summary>
        ///
        /// </summary>
        WhereBetweenCallExpressionParameter Between { get; }
    }

    /// <summary>
    /// 函数表达式描述器。
    /// </summary>
    public class WhereCallExpressionDescriptor : IWhereCallExpressionDescriptor
    {
        /// <summary>
        ///
        /// </summary>
        public WhereLikeCallExpressionParameter Like { get; set; }

        /// <summary>
        ///
        /// </summary>
        public WhereInCallExpressionParameter In { get; set; }

        /// <summary>
        ///
        /// </summary>
        public WhereNotInCallExpressionParameter NotIn { get; set; }

        /// <summary>
        ///
        /// </summary>
        public WhereBetweenCallExpressionParameter Between { get; set; }
    }

    /// <summary>
    /// Like
    /// </summary>
    public class WhereLikeCallExpressionParameter
    {
        /// <summary>
        ///
        /// </summary>
        public WhereLikeCallExpressionParameterType Type { get; set; }

        /// <summary>
        /// 参数名。
        /// </summary>
        public string ParameterName { get; set; }

        /// <summary>
        /// 参数值。
        /// </summary>
        public object ParameterValue { get; set; }
    }

    /// <summary>
    /// LIKE 类型。
    /// </summary>
    public enum WhereLikeCallExpressionParameterType
    {
        /// <summary>
        /// 包含关键字。
        /// </summary>
        Equal = 0,

        /// <summary>
        /// 从首字符开始匹配。
        /// </summary>
        StartsWith = 1,

        /// <summary>
        /// 匹配结尾字符。
        /// </summary>
        EndsWith = 2
    }

    /// <summary>
    /// In
    /// </summary>
    public class WhereInCallExpressionParameter
    {
        /// <summary>
        /// 参数名。
        /// </summary>
        public string ParameterName { get; set; }

        /// <summary>
        /// 参数值。
        /// </summary>
        public List<object> ParameterValue { get; set; } = new List<object>();
    }

    /// <summary>
    /// Not In
    /// </summary>
    public class WhereNotInCallExpressionParameter
    {
        /// <summary>
        /// 参数名。
        /// </summary>
        public string ParameterName { get; set; }

        /// <summary>
        /// 参数值。
        /// </summary>
        public List<object> ParameterValue { get; set; } = new List<object>();
    }

    /// <summary>
    /// Between
    /// </summary>
    public class WhereBetweenCallExpressionParameter
    {
        /// <summary>
        /// 参数名。
        /// </summary>
        public string ParameterName { get; set; }

        /// <summary>
        /// 最小值。
        /// </summary>
        public object StartValue { get; set; }

        /// <summary>
        /// 最大值。
        /// </summary>
        public object EndValue { get; set; }
    }
}